<?php

class ContactController extends Controller
{
	public function actionIndex()
	{
	   $model = new Articles();
      $list = array();
      $page = Yii::app()->request->getParam('page',1);
      $limit = 2;
      $offset = $page*$limit - $limit;
      $object = $model->findAllByAttributes(array('art_cat_id' => 4),
                                             array('order' => 'art_date_modify desc',
                                                   'offset' => $offset,
                                                   'limit' => $limit,
                                                   ));
      if(count($object) > 0){
         foreach($object as $item){
            $list[] = $item->attributes;
         }
      }
		$this->render('index',array('model' => $model,
                                 'list' => $list,
                                 ));
	}
   
   /**
    * Displays page detail
   */
   public function actionDetail(){
      
      $id = Yii::app()->request->getParam('id',0);
      $article = array();
      $model = new Articles();
      $object = $model->findByPk($id);
      if($object != null){
         $article = $object->attributes;
      }
      
      $this->render('detail',array('model' => $model,
                                    'article' => $article));
   }

	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}